#include <OgreRoot.h>
#include <OgreLog.h>
#include <OgrePrerequisites.h>

#define DLL_EXPORT __declspec(dllexport)

using namespace Ogre;

//LogListener class:

typedef void (*fp)(void *ptrToWrapper, const char*, LogMessageLevel, bool, const char*);

class LogListenerWrapper : public LogListener
{
    public:
    fp ptrToFunc;
    void messageLogged(const String &message, LogMessageLevel lml, bool maskDebug, const String &logName)
    {
        if(ptrToFunc)
        {
            ptrToFunc(this, message.c_str(), lml, maskDebug, logName.c_str());
        }
    }
};

extern "C" DLL_EXPORT void *getLogListenerWrapper(fp ptrToF)
{
    LogListenerWrapper *wrapper = new LogListenerWrapper();
    wrapper->ptrToFunc = ptrToF;
    return wrapper;
}






//Log class

extern "C" DLL_EXPORT void *getLog(const char *name, bool debugOutput, bool suppressFileOutput)
{
    return new Log((String)name, debugOutput, suppressFileOutput);
}

extern "C" DLL_EXPORT void call_addListener(Log *ptr, LogListenerWrapper *ptrToListener)
{
    ptr->addListener(ptrToListener);
}

